// pages/main/pirce/price.js
let myThis
const app = getApp()
const http = require('../../../utils/request.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    showModal: false,
    params: {},
    role_type: 0,
    showModal2: false

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {

  },
  onShow: function() {
    myThis = this

    myThis.detail()
  },
  detail() {
    http.ordinary.call(this, 'myReward', {}, this.datafun, 1, true)
  },
  confirm() {
    console.log('点击申请成为商户')
    let role_type = app.globalData.server.role_type ? app.globalData.server.role_type : 0
    this.setData({
      role_type
    })
    if (role_type==1){return}
    let sig_status = app.globalData.server.sig_status
    let sig_pay_status = app.globalData.server.sig_pay_status
    let server_id = app.globalData.server.server_id
    let pay_type = app.globalData.server.pay_type
    if (sig_status == 0) {
      wx.navigateTo({
        url: '/pages/h5/index?url=' + app.UrlEncode(`https://h5.ameimeika.com/ElectronicProtocolH5/index.html`),
      })
    } else if (sig_status == 1) {
      wx.navigateTo({
        url: '/pages/h5/index?url=' + app.UrlEncode(`https://h5.ameimeika.com/ElectronicProtocolH5/legalRz_sq.html`),
      })
    } else if (sig_status == 2) {
      wx.navigateTo({
        url: '/pages/h5/index?url=' + app.UrlEncode(`https://h5.ameimeika.com/ElectronicProtocolH5/legalRz_sb.html`),
      })
    } else if (sig_status == 3) {
      wx.navigateTo({
        url: '/pages/h5/index?url=' + app.UrlEncode(`https://h5.ameimeika.com/ElectronicProtocolH5/legalRz_tg.html`),
      })
    } else if (sig_pay_status == 2 && (sig_status == 5 || sig_status == 6)) {
      let type
      if (sig_status == 5) {
        type = 5
      } else {
        type = 6
      }
      wx.navigateTo({
        url: '/pages/h5/index?url=' + app.UrlEncode(`https://h5.ameimeika.com/ElectronicProtocolH5/examine.html?type=${type}`),
      })
    } else if (sig_pay_status == 1 && sig_status == 4 && pay_type != 4) {
      wx.navigateTo({
        url: '/pages/h5/index?url=' + app.UrlEncode(`https://h5.ameimeika.com/ElectronicProtocolH5/confirmPay.html`),
      })
    }
  },
  confirm22() {
    console.log('他确定了')
    this.setData({
      role_type: 0
    })
  },
  datafun(datas) {
    console.log(datas)
    myThis.setData({
      params: datas
    })
  },
  closemodal() {
    this.setData({
      showModal: false
    })
  },
  checkfun: function() {
    wx.navigateTo({
      url: '/pages/circle/withdraw/withdraw/withdraw?draw=1',
    })
    // else {
    //   myThis.setData({
    //     showModal: true
    //   })
    // }

  },
  godetail: function() {
    wx.navigateTo({
      url: '/pages/main/pricedetail/pricedetail',
    })
  },
  modalCancel: function() {


  },
  modalConfirm: function() {
    console.log(5555)
    // if(this.data.role_type==1){
    //   this.setData({
    //     iszjl:true
    //   })
    // }

  }
})